package org.journal.service;

import java.util.Calendar;
import java.util.GregorianCalendar;

import org.springframework.stereotype.Service;

@Service
public class TimeServiceImpl implements TimeService {

	private static final int FIRST_DAY_NUMBER = 1;

	public int getCurrentMonthDaysCount() {
		Calendar calendar = new GregorianCalendar();

		return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
	}

	public int getMonthDaysCount(int year, int month) {

		// months count starting from 0 to 11, thats why we decrease month by 1
		Calendar calendar = new GregorianCalendar(year, month - 1,
				FIRST_DAY_NUMBER);

		return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
	}

}
